\hypertarget{group__spi}{\subsection{S\-P\-I access}
\label{group__spi}\index{S\-P\-I access@{S\-P\-I access}}
}
\subsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{group__spi_gac888dc9b78b695f6c13eeeaa813c0d82}{bcm2835\-\_\-spi\-\_\-begin} (void)
\item 
void \hyperlink{group__spi_gad25421b3a4a6ca280dfdd39c94c3279a}{bcm2835\-\_\-spi\-\_\-end} (void)
\item 
void \hyperlink{group__spi_ga0127eab1b6c3f8bf127bdac474fdc0f9}{bcm2835\-\_\-spi\-\_\-set\-Bit\-Order} (uint8\-\_\-t order)
\begin{DoxyCompactList}\small\item\em see \hyperlink{group__constants_ga1dd00efbd834646f75240c39a41c9856}{bcm2835\-S\-P\-I\-Bit\-Order} \end{DoxyCompactList}\item 
void \hyperlink{group__spi_gad623657d9513faa89d22ae1dc87eec38}{bcm2835\-\_\-spi\-\_\-set\-Clock\-Divider} (uint16\-\_\-t divider)
\begin{DoxyCompactList}\small\item\em see \hyperlink{group__constants_gaf2e0ca069b8caef24602a02e8a00884e}{bcm2835\-S\-P\-I\-Clock\-Divider} \end{DoxyCompactList}\item 
void \hyperlink{group__spi_gabfbf797499756d38e3667f05ee8fd11d}{bcm2835\-\_\-spi\-\_\-set\-Data\-Mode} (uint8\-\_\-t mode)
\begin{DoxyCompactList}\small\item\em see \hyperlink{group__constants_ga8dd7bb496565324800130100e6bf6d86}{bcm2835\-S\-P\-I\-Mode} \end{DoxyCompactList}\item 
void \hyperlink{group__spi_ga2fa186568605c21e9166a19b1d82ea95}{bcm2835\-\_\-spi\-\_\-chip\-Select} (uint8\-\_\-t cs)
\item 
void \hyperlink{group__spi_gaee4edaf16fe21455441965bc57e78724}{bcm2835\-\_\-spi\-\_\-set\-Chip\-Select\-Polarity} (uint8\-\_\-t cs, uint8\-\_\-t active)
\item 
uint8\-\_\-t \hyperlink{group__spi_ga600dc972f1064908b41b349c92d7647d}{bcm2835\-\_\-spi\-\_\-transfer} (uint8\-\_\-t value)
\item 
void \hyperlink{group__spi_gac24692f270bb3411990ea706ddd4fee9}{bcm2835\-\_\-spi\-\_\-transfernb} (char $\ast$tbuf, char $\ast$rbuf, uint32\-\_\-t len)
\item 
void \hyperlink{group__spi_ga06884e9cd71dfe380f846b09f47b7248}{bcm2835\-\_\-spi\-\_\-transfern} (char $\ast$buf, uint32\-\_\-t len)
\end{DoxyCompactItemize}


\subsubsection{Detailed Description}
These functions let you use S\-P\-I0 (Serial Peripheral Interface) to interface with an external S\-P\-I device. 

\subsubsection{Function Documentation}
\hypertarget{group__spi_gac888dc9b78b695f6c13eeeaa813c0d82}{\index{S\-P\-I access@{S\-P\-I access}!bcm2835\-\_\-spi\-\_\-begin@{bcm2835\-\_\-spi\-\_\-begin}}
\index{bcm2835\-\_\-spi\-\_\-begin@{bcm2835\-\_\-spi\-\_\-begin}!SPI access@{S\-P\-I access}}
\paragraph[{bcm2835\-\_\-spi\-\_\-begin}]{\setlength{\rightskip}{0pt plus 5cm}void bcm2835\-\_\-spi\-\_\-begin (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}\label{group__spi_gac888dc9b78b695f6c13eeeaa813c0d82}
Start S\-P\-I operations. Forces R\-Pi S\-P\-I0 pins P1-\/19 (M\-O\-S\-I), P1-\/21 (M\-I\-S\-O), P1-\/23 (C\-L\-K), P1-\/24 (C\-E0) and P1-\/26 (C\-E1) to alternate function A\-L\-T0, which enables those pins for S\-P\-I interface. You should call \hyperlink{group__spi_gad25421b3a4a6ca280dfdd39c94c3279a}{bcm2835\-\_\-spi\-\_\-end()} when all S\-P\-I funcitons are complete to return the pins to their default functions \begin{DoxySeeAlso}{See Also}
\hyperlink{group__spi_gad25421b3a4a6ca280dfdd39c94c3279a}{bcm2835\-\_\-spi\-\_\-end()} 
\end{DoxySeeAlso}


Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{group__spi_gac888dc9b78b695f6c13eeeaa813c0d82_cgraph}
\end{center}
\end{figure}


\hypertarget{group__spi_ga2fa186568605c21e9166a19b1d82ea95}{\index{S\-P\-I access@{S\-P\-I access}!bcm2835\-\_\-spi\-\_\-chip\-Select@{bcm2835\-\_\-spi\-\_\-chip\-Select}}
\index{bcm2835\-\_\-spi\-\_\-chip\-Select@{bcm2835\-\_\-spi\-\_\-chip\-Select}!SPI access@{S\-P\-I access}}
\paragraph[{bcm2835\-\_\-spi\-\_\-chip\-Select}]{\setlength{\rightskip}{0pt plus 5cm}void bcm2835\-\_\-spi\-\_\-chip\-Select (
\begin{DoxyParamCaption}
\item[{uint8\-\_\-t}]{cs}
\end{DoxyParamCaption}
)}}\label{group__spi_ga2fa186568605c21e9166a19b1d82ea95}
Sets the chip select pin(s) When an \hyperlink{group__spi_ga600dc972f1064908b41b349c92d7647d}{bcm2835\-\_\-spi\-\_\-transfer()} is made, the selected pin(s) will be asserted during the transfer. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cs} & Specifies the C\-S pins(s) that are used to activate the desired slave. One of B\-C\-M2835\-\_\-\-S\-P\-I\-\_\-\-C\-S$\ast$, see \hyperlink{group__constants_ga29bba154633d37d07fa130a86e4a1f2a}{bcm2835\-S\-P\-I\-Chip\-Select} \\
\hline
\end{DoxyParams}


Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{group__spi_ga2fa186568605c21e9166a19b1d82ea95_cgraph}
\end{center}
\end{figure}


\hypertarget{group__spi_gad25421b3a4a6ca280dfdd39c94c3279a}{\index{S\-P\-I access@{S\-P\-I access}!bcm2835\-\_\-spi\-\_\-end@{bcm2835\-\_\-spi\-\_\-end}}
\index{bcm2835\-\_\-spi\-\_\-end@{bcm2835\-\_\-spi\-\_\-end}!SPI access@{S\-P\-I access}}
\paragraph[{bcm2835\-\_\-spi\-\_\-end}]{\setlength{\rightskip}{0pt plus 5cm}void bcm2835\-\_\-spi\-\_\-end (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}\label{group__spi_gad25421b3a4a6ca280dfdd39c94c3279a}
End S\-P\-I operations. S\-P\-I0 pins P1-\/19 (M\-O\-S\-I), P1-\/21 (M\-I\-S\-O), P1-\/23 (C\-L\-K), P1-\/24 (C\-E0) and P1-\/26 (C\-E1) are returned to their default I\-N\-P\-U\-T behaviour. 

Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{group__spi_gad25421b3a4a6ca280dfdd39c94c3279a_cgraph}
\end{center}
\end{figure}


\hypertarget{group__spi_ga0127eab1b6c3f8bf127bdac474fdc0f9}{\index{S\-P\-I access@{S\-P\-I access}!bcm2835\-\_\-spi\-\_\-set\-Bit\-Order@{bcm2835\-\_\-spi\-\_\-set\-Bit\-Order}}
\index{bcm2835\-\_\-spi\-\_\-set\-Bit\-Order@{bcm2835\-\_\-spi\-\_\-set\-Bit\-Order}!SPI access@{S\-P\-I access}}
\paragraph[{bcm2835\-\_\-spi\-\_\-set\-Bit\-Order}]{\setlength{\rightskip}{0pt plus 5cm}void bcm2835\-\_\-spi\-\_\-set\-Bit\-Order (
\begin{DoxyParamCaption}
\item[{uint8\-\_\-t}]{order}
\end{DoxyParamCaption}
)}}\label{group__spi_ga0127eab1b6c3f8bf127bdac474fdc0f9}


see \hyperlink{group__constants_ga1dd00efbd834646f75240c39a41c9856}{bcm2835\-S\-P\-I\-Bit\-Order} 

Sets the S\-P\-I bit order N\-O\-T\-E\-: has no effect. Not supported by S\-P\-I0. Defaults to 
\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em order} & The desired bit order, one of B\-C\-M2835\-\_\-\-S\-P\-I\-\_\-\-B\-I\-T\-\_\-\-O\-R\-D\-E\-R\-\_\-$\ast$, \\
\hline
\end{DoxyParams}
\hypertarget{group__spi_gaee4edaf16fe21455441965bc57e78724}{\index{S\-P\-I access@{S\-P\-I access}!bcm2835\-\_\-spi\-\_\-set\-Chip\-Select\-Polarity@{bcm2835\-\_\-spi\-\_\-set\-Chip\-Select\-Polarity}}
\index{bcm2835\-\_\-spi\-\_\-set\-Chip\-Select\-Polarity@{bcm2835\-\_\-spi\-\_\-set\-Chip\-Select\-Polarity}!SPI access@{S\-P\-I access}}
\paragraph[{bcm2835\-\_\-spi\-\_\-set\-Chip\-Select\-Polarity}]{\setlength{\rightskip}{0pt plus 5cm}void bcm2835\-\_\-spi\-\_\-set\-Chip\-Select\-Polarity (
\begin{DoxyParamCaption}
\item[{uint8\-\_\-t}]{cs, }
\item[{uint8\-\_\-t}]{active}
\end{DoxyParamCaption}
)}}\label{group__spi_gaee4edaf16fe21455441965bc57e78724}
Sets the chip select pin polarity for a given pin When an \hyperlink{group__spi_ga600dc972f1064908b41b349c92d7647d}{bcm2835\-\_\-spi\-\_\-transfer()} occurs, the currently selected chip select pin(s) will be asserted to the value given by active. When transfers are not happening, the chip select pin(s) return to the complement (inactive) value. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cs} & The chip select pin to affect \\
\hline
\mbox{\tt in}  & {\em active} & Whether the chip select pin is to be active H\-I\-G\-H \\
\hline
\end{DoxyParams}


Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{group__spi_gaee4edaf16fe21455441965bc57e78724_cgraph}
\end{center}
\end{figure}


\hypertarget{group__spi_gad623657d9513faa89d22ae1dc87eec38}{\index{S\-P\-I access@{S\-P\-I access}!bcm2835\-\_\-spi\-\_\-set\-Clock\-Divider@{bcm2835\-\_\-spi\-\_\-set\-Clock\-Divider}}
\index{bcm2835\-\_\-spi\-\_\-set\-Clock\-Divider@{bcm2835\-\_\-spi\-\_\-set\-Clock\-Divider}!SPI access@{S\-P\-I access}}
\paragraph[{bcm2835\-\_\-spi\-\_\-set\-Clock\-Divider}]{\setlength{\rightskip}{0pt plus 5cm}void bcm2835\-\_\-spi\-\_\-set\-Clock\-Divider (
\begin{DoxyParamCaption}
\item[{uint16\-\_\-t}]{divider}
\end{DoxyParamCaption}
)}}\label{group__spi_gad623657d9513faa89d22ae1dc87eec38}


see \hyperlink{group__constants_gaf2e0ca069b8caef24602a02e8a00884e}{bcm2835\-S\-P\-I\-Clock\-Divider} 

Sets the S\-P\-I clock divider and therefore the S\-P\-I clock speed. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em divider} & The desired S\-P\-I clock divider, one of B\-C\-M2835\-\_\-\-S\-P\-I\-\_\-\-C\-L\-O\-C\-K\-\_\-\-D\-I\-V\-I\-D\-E\-R\-\_\-$\ast$, \\
\hline
\end{DoxyParams}


Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{group__spi_gad623657d9513faa89d22ae1dc87eec38_cgraph}
\end{center}
\end{figure}


\hypertarget{group__spi_gabfbf797499756d38e3667f05ee8fd11d}{\index{S\-P\-I access@{S\-P\-I access}!bcm2835\-\_\-spi\-\_\-set\-Data\-Mode@{bcm2835\-\_\-spi\-\_\-set\-Data\-Mode}}
\index{bcm2835\-\_\-spi\-\_\-set\-Data\-Mode@{bcm2835\-\_\-spi\-\_\-set\-Data\-Mode}!SPI access@{S\-P\-I access}}
\paragraph[{bcm2835\-\_\-spi\-\_\-set\-Data\-Mode}]{\setlength{\rightskip}{0pt plus 5cm}void bcm2835\-\_\-spi\-\_\-set\-Data\-Mode (
\begin{DoxyParamCaption}
\item[{uint8\-\_\-t}]{mode}
\end{DoxyParamCaption}
)}}\label{group__spi_gabfbf797499756d38e3667f05ee8fd11d}


see \hyperlink{group__constants_ga8dd7bb496565324800130100e6bf6d86}{bcm2835\-S\-P\-I\-Mode} 

Sets the S\-P\-I data mode Sets the clock polariy and phase 
\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em mode} & The desired data mode, one of B\-C\-M2835\-\_\-\-S\-P\-I\-\_\-\-M\-O\-D\-E$\ast$, \\
\hline
\end{DoxyParams}


Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{group__spi_gabfbf797499756d38e3667f05ee8fd11d_cgraph}
\end{center}
\end{figure}


\hypertarget{group__spi_ga600dc972f1064908b41b349c92d7647d}{\index{S\-P\-I access@{S\-P\-I access}!bcm2835\-\_\-spi\-\_\-transfer@{bcm2835\-\_\-spi\-\_\-transfer}}
\index{bcm2835\-\_\-spi\-\_\-transfer@{bcm2835\-\_\-spi\-\_\-transfer}!SPI access@{S\-P\-I access}}
\paragraph[{bcm2835\-\_\-spi\-\_\-transfer}]{\setlength{\rightskip}{0pt plus 5cm}uint8\-\_\-t bcm2835\-\_\-spi\-\_\-transfer (
\begin{DoxyParamCaption}
\item[{uint8\-\_\-t}]{value}
\end{DoxyParamCaption}
)}}\label{group__spi_ga600dc972f1064908b41b349c92d7647d}
Transfers one byte to and from the currently selected S\-P\-I slave. Asserts the currently selected C\-S pins (as previously set by bcm2835\-\_\-spi\-\_\-chip\-Select) during the transfer. Clocks the 8 bit value out on M\-O\-S\-I, and simultaneously clocks in data from M\-I\-S\-O. Returns the read data byte from the slave. Uses polled transfer as per section 10.\-6.\-1 of teh B\-C\-M 2835 A\-R\-M Peripherls manual 
\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em value} & The 8 bit data byte to write to M\-O\-S\-I \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The 8 bit byte simultaneously read from M\-I\-S\-O 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__spi_ga06884e9cd71dfe380f846b09f47b7248}{bcm2835\-\_\-spi\-\_\-transfern()} 
\end{DoxySeeAlso}


Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{group__spi_ga600dc972f1064908b41b349c92d7647d_cgraph}
\end{center}
\end{figure}


\hypertarget{group__spi_ga06884e9cd71dfe380f846b09f47b7248}{\index{S\-P\-I access@{S\-P\-I access}!bcm2835\-\_\-spi\-\_\-transfern@{bcm2835\-\_\-spi\-\_\-transfern}}
\index{bcm2835\-\_\-spi\-\_\-transfern@{bcm2835\-\_\-spi\-\_\-transfern}!SPI access@{S\-P\-I access}}
\paragraph[{bcm2835\-\_\-spi\-\_\-transfern}]{\setlength{\rightskip}{0pt plus 5cm}void bcm2835\-\_\-spi\-\_\-transfern (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{buf, }
\item[{uint32\-\_\-t}]{len}
\end{DoxyParamCaption}
)}}\label{group__spi_ga06884e9cd71dfe380f846b09f47b7248}
Transfers any number of bytes to and from the currently selected S\-P\-I slave using bcm2835\-\_\-spi\-\_\-transfernb. The returned data from the slave replaces the transmitted data in the buffer. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em buf} & Buffer of bytes to send. Received bytes will replace the contents \\
\hline
\mbox{\tt in}  & {\em len} & Number of bytes int eh buffer, and the number of bytes to send/received \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__spi_ga600dc972f1064908b41b349c92d7647d}{bcm2835\-\_\-spi\-\_\-transfer()} 
\end{DoxySeeAlso}


Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{group__spi_ga06884e9cd71dfe380f846b09f47b7248_cgraph}
\end{center}
\end{figure}


\hypertarget{group__spi_gac24692f270bb3411990ea706ddd4fee9}{\index{S\-P\-I access@{S\-P\-I access}!bcm2835\-\_\-spi\-\_\-transfernb@{bcm2835\-\_\-spi\-\_\-transfernb}}
\index{bcm2835\-\_\-spi\-\_\-transfernb@{bcm2835\-\_\-spi\-\_\-transfernb}!SPI access@{S\-P\-I access}}
\paragraph[{bcm2835\-\_\-spi\-\_\-transfernb}]{\setlength{\rightskip}{0pt plus 5cm}void bcm2835\-\_\-spi\-\_\-transfernb (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{tbuf, }
\item[{char $\ast$}]{rbuf, }
\item[{uint32\-\_\-t}]{len}
\end{DoxyParamCaption}
)}}\label{group__spi_gac24692f270bb3411990ea706ddd4fee9}
Transfers any number of bytes to and from the currently selected S\-P\-I slave. Asserts the currently selected C\-S pins (as previously set by bcm2835\-\_\-spi\-\_\-chip\-Select) during the transfer. Clocks the len 8 bit bytes out on M\-O\-S\-I, and simultaneously clocks in data from M\-I\-S\-O. The data read read from the slave is placed into rbuf. rbuf must be at least len bytes long Uses polled transfer as per section 10.\-6.\-1 of the B\-C\-M 2835 A\-R\-M Peripherls manual 
\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em tbuf} & Buffer of bytes to send. \\
\hline
\mbox{\tt out}  & {\em rbuf} & Received bytes will by put in this buffer \\
\hline
\mbox{\tt in}  & {\em len} & Number of bytes in the tbuf buffer, and the number of bytes to send/received \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__spi_ga600dc972f1064908b41b349c92d7647d}{bcm2835\-\_\-spi\-\_\-transfer()} 
\end{DoxySeeAlso}


Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{group__spi_gac24692f270bb3411990ea706ddd4fee9_cgraph}
\end{center}
\end{figure}


